Contrast detection autofocus using adaptive step

ABSTRACT

A method for moving an optical device relative to an image sensor to focus an image includes obtaining a first contrast value of a first image captured by the image sensor at a first moment and a first contrast variation rate of the first image, determining, according to the first contrast value and the first contrast variation rate, a first position of the optical device at the first moment, moving the optical device from the first position to a second position corresponding to a second moment subsequent to the first moment, and in response to a second contrast variation value being a preset value, determining a current position of the optical device to be the second position corresponding to the second contrast variation value.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of U.S. application Ser. No.17/025,949, filed on Sep. 18, 2020, which is a continuation of U.S.patent application Ser. No. 16/113,852, filed on Aug. 27, 2018, which isa continuation of International Application No. PCT/CN2016/079506, filedon Apr. 15, 2016, the entire contents of all of which are incorporatedherein by reference.

TECHNICAL FIELD

The disclosed embodiments relate generally to focusing an image and moreparticularly, but not exclusively, to a contrast detection focusingoperation that iteratively adjusts the amount by which a distancebetween an optical device and an image sensor is increased.

BACKGROUND

Contrast detection autofocus techniques typically rely on adjustingcamera focus until an optimal focus point is passed in order to home inon the optical focus point. When a camera is a component of a UAV,adjusting camera focus presents unique challenges, particularly if theadjustment is to be made while the UAV is in flight. Reducing themovement of an optical component of a UAV is beneficial for imagestability and flight control.

SUMMARY

There is a need for systems and methods for moving an optical devicerelative to an image sensor to focus an image. Such systems and methodsoptionally complement or replace conventional methods for moving anoptical device relative to an image sensor to focus an image.

In accordance with some embodiments, a method for moving an opticaldevice relative to an image sensor to focus an image comprises:acquiring, by the image sensor, a first image when the optical device isat a first position relative to the image sensor; obtaining a firstcontrast value of the first image and a first contrast variation rate atthe first position; and determining whether the first contrast variationrate meets a first threshold criterion. In accordance with adetermination that the contrast variation rate meets the first thresholdcriterion: a first step size is determined, wherein the first step sizeis greater than a previous step size used for moving the optical deviceto the first position, and the optical device is moved from the firstposition to a second position according to the first step size. Inaccordance with a determination that the first contrast variation ratedoes not meet the first threshold criterion: a second step size isdetermined, wherein the second step size is smaller than the previousstep size used for moving the optical device to the first position, andthe optical device is moved from the first position to the secondposition according to the second step size. The aforementionedoperations are repeated until a second contrast variation rate for asecond image meets a second threshold criterion, wherein the secondimage is acquired when the optical device is at the second position.

In accordance with some embodiments, a system for moving an opticaldevice relative to an image sensor to focus an image comprises one ormore processors and an imaging device comprising an image sensor and anoptical device. The one or more processors are configured for:acquiring, by the image sensor, a first image when the optical device isat a first position relative to the image sensor; obtaining a firstcontrast value of the first image and a first contrast variation rate atthe first position; and determining whether the first contrast variationrate meets a first threshold criterion. The one or more processors arefurther configured for, in accordance with a determination that thecontrast variation rate meets the first threshold criterion: determininga first step size, wherein the first step size is greater than aprevious step size used for moving the optical device to the firstposition, and moving the optical device from the first position to asecond position according to the first step size. The one or moreprocessors are further configured for, in accordance with adetermination that the first contrast variation rate does not meet thefirst threshold criterion: determining a second step size, wherein thesecond step size is smaller than the previous step size used for movingthe optical device to the first position, and moving the optical devicefrom the first position to the second position according to the secondstep size. The one or more processors are further configured forrepeating the aforementioned operations until a second contrastvariation rate for a second image meets a second threshold criterion,wherein the second image is acquired when the optical device is at thesecond position.

In accordance with some embodiments, an unmanned aerial vehicle (UAV)comprises a propulsion system, an imaging device comprising an imagesensor and an optical device, and one or more processors. The one ormore processors are configured for: acquiring, by the image sensor, afirst image when the optical device is at a first position relative tothe image sensor; obtaining a first contrast value of the first imageand a first contrast variation rate at the first position; anddetermining whether the first contrast variation rate meets a firstthreshold criterion. The one or more processors are further configuredfor, in accordance with a determination that the contrast variation ratemeets the first threshold criterion: determining a first step size,wherein the first step size is greater than a previous step size usedfor moving the optical device to the first position, and moving theoptical device from the first position to a second position according tothe first step size. The one or more processors are further configuredfor, in accordance with a determination that the first contrastvariation rate does not meet the first threshold criterion: determininga second step size, wherein the second step size is smaller than theprevious step size used for moving the optical device to the firstposition, and moving the optical device from the first position to thesecond position according to the second step size. The one or moreprocessors are further configured for repeating the aforementionedoperations until a second contrast variation rate for a second imagemeets a second threshold criterion, wherein the second image is acquiredwhen the optical device is at the second position.

In accordance with some embodiments, a computer readable storage mediumstores one or more programs, the one or more programs comprisinginstructions, which when executed, cause an imaging device to: acquire,by an image sensor, a first image when an optical device is at a firstposition relative to the image sensor; obtain a first contrast value ofthe first image and a first contrast variation rate at the firstposition; and determine whether the first contrast variation rate meetsa first threshold criterion. The one or more programs further cause theimaging device to, in accordance with a determination that the contrastvariation rate meets the first threshold criterion: determine a firststep size, wherein the first step size is greater than a previous stepsize used for moving the optical device to the first position, and movethe optical device from the first position to a second positionaccording to the first step size. The one or more programs further causethe imaging device to, in accordance with a determination that the firstcontrast variation rate does not meet the first threshold criterion:determine a second step size, wherein the second step size is smallerthan the previous step size used for moving the optical device to thefirst position, and move the optical device from the first position tothe second position according to the second step size. The one or moreprograms further cause the imaging device to repeat the aforementionedoperations until a second contrast variation rate for a second imagemeets a second threshold criterion, wherein the second image is acquiredwhen the optical device is at the second position.

BRIEF DESCRIPTION OF THE DRAWINGS

FIGS. 1A-1B illustrate movable object environments, in accordance withsome embodiments.

FIG. 2A illustrates a movable object in the movable object environmentof FIG. 1A, in accordance with some embodiments.

FIG. 2B illustrates a movable object in the movable object environmentof FIG. 1B, in accordance with some embodiments.

FIG. 3 illustrates an exemplary movable object sensing system, inaccordance with some embodiments.

FIG. 4 is a cross sectional view of an exemplary imaging device, inaccordance with some embodiments.

FIG. 5 illustrates contrast variation determination for an exemplaryimage captured by an image sensor, in accordance with some embodiments.

FIGS. 6A-6C illustrate a simplified representation of locations at whichlight rays corresponding to an object converge based on variousseparation distances between an optical device and an image sensor, inaccordance with some embodiments.

FIGS. 6D-6F illustrate contrast distributions corresponding to therespective separation distances illustrated in FIGS. 6A-6C, inaccordance with some embodiments.

FIG. 6G-6I illustrate pixel arrays corresponding to the respectiveseparation distances illustrated in FIGS. 6A-6C, in accordance with someembodiments.

FIG. 7 illustrates exemplary contrast values obtained for imagescaptured at various distances between an optical device and an imagesensor, in accordance with some embodiments.

FIG. 8A illustrates a cubic Bézier curve determined for obtainedcontrast values, in accordance with some embodiments.

FIG. 8B illustrates determined values corresponding to an estimateddistance between an optical device and an image sensor at which an imagecaptured by image sensor will be focused, in accordance with someembodiments.

FIG. 8C illustrates a contrast value determined after the distancebetween an optical device and an image sensor has been increased by adetermined step size, in accordance with some embodiments.

FIG. 8D illustrates various threshold values to which determinedcontrast variation rates are compared, in accordance with variousembodiments.

FIGS. 9A-9C are a flow diagram illustrating a method for moving anoptical device relative to an image sensor to focus an image, inaccordance with some embodiments.

FIGS. 10A and 10B illustrate exemplary contrast distributions over arange from a minimum distance between an optical device and an imagesensor to a maximum distance between the optical device and the imagesensor.

FIGS. 11A-11D are a flow diagram illustrating a method for moving anoptical device relative to an image sensor to focus an image, inaccordance with some embodiments.

DETAILED DESCRIPTION

Reference will now be made in detail to embodiments, examples of whichare illustrated in the accompanying drawings. In the following detaileddescription, numerous specific details are set forth in order to providea thorough understanding of the various described embodiments. However,it will be apparent to one of ordinary skill in the art that the variousdescribed embodiments may be practiced without these specific details.In other instances, well-known methods, procedures, components,circuits, and networks have not been described in detail so as not tounnecessarily obscure aspects of the embodiments.

The following description uses an unmanned aerial vehicle (UAV) as anexample of a movable object. UAVs include, e.g., fixed-wing aircraftsand rotary-wing aircrafts such as helicopters, quadcopters, and aircrafthaving other numbers and/or configurations of rotors. It will beapparent to those skilled in the art that other types of movable objectsmay be substituted for UAVs as described below.

Techniques related to optical adjustments for movable objects such asUAVs are described herein.

FIG. 1A illustrates a movable object environment 100, in accordance withsome embodiments. The movable object environment 100 includes a movableobject 102. In some embodiments, the movable object 102 includes acarrier 104 and/or a payload 106.

In some embodiments, the carrier 104 is used to couple a payload 106 tomovable object 102. In some embodiments, the carrier 104 includes anelement (e.g., a gimbal and/or damping element) to isolate the payload106 from movement of the movable object 102 and/or the movementmechanism 114. In some embodiments, the carrier 104 includes an elementfor controlling movement of the payload 106 relative to the movableobject 102.

In some embodiments, the payload 106 is coupled (e.g., rigidly coupled)to the movable object 102 (e.g., coupled via carrier 104) such that thepayload 106 remains substantially stationary relative to movable object102. For example, the carrier 104 is coupled to the payload 106 suchthat the payload is not movable relative to the movable object 102. Insome embodiments, the payload 106 is mounted directly to the movableobject 102 without requiring the carrier 104. In some embodiments, thepayload 106 is located partially or fully within the movable object 102.

In some embodiments, the control unit 108 communicates with the movableobject 102, e.g., to provide control instructions to the movable object102 and/or to display information received from the movable object 102.Although the control unit 108 is typically a portable (e.g., handheld)device, control unit 108 need not be portable. In some embodiments, thecontrol unit 108 is a dedicated control device (e.g., for the movableobject 102), a laptop computer, a desktop computer, a tablet computer, agaming system, a wearable device (e.g., glasses, a glove, and/or ahelmet), a microphone, a portable communication device (e.g., a mobiletelephone) and/or a combination thereof.

In some embodiments, an input device of the control unit 108 receivesuser input to control aspects of the movable object 102, the carrier104, the payload 106, and/or a component thereof. Such aspects include,e.g., attitude, position, orientation, velocity, acceleration,navigation, and/or tracking. For example, a position of an input deviceof the control unit 108 (e.g., a position of a component of inputdevice) is manually set by a user to a position corresponding to aninput (e.g., a predetermined input) for controlling the movable object102. In some embodiments, the input device is manipulated by a user toinput control instructions for controlling the navigation of the movableobject 102. In some embodiments, an input device of control unit 108 isused to input a flight mode for the movable object 102, such as autopilot or navigation according to a predetermined navigation path.

In some embodiments, a display of the control unit 108 displaysinformation generated by the movable object sensing system 210, thememory 204, and/or another system of the movable object 102. Forexample, the display displays information about the movable object 102,the carrier 104, and/or the payload 106, such as position, attitude,orientation, movement characteristics of the movable object 102, and/ordistance between the movable object 102 and another object (e.g., atarget and/or an obstacle). In some embodiments, information displayedby a display of control unit 108 includes images captured by the imagingdevice 302, tracking data (e.g., a graphical tracking indicator appliedto a representation of a target), and/or indications of control datatransmitted to the movable object 102. In some embodiments, informationdisplayed by the display of the control unit 108 is displayed insubstantially real-time as information is received from the movableobject 102 and/or as image data is acquired. In some embodiments, thedisplay of the control unit 108 is a touchscreen display.

In some embodiments, the computing device 110 is, e.g., a servercomputer, desktop computer, a laptop computer, a tablet, or anotherportable electronic device (e.g., a mobile telephone). In someembodiments, the computing device 110 is a base station thatcommunicates (e.g., wirelessly) with the movable object 102 and/or thecontrol unit 108. In some embodiments, the computing device 110 providesdata storage, data retrieval, and/or data processing operations, e.g.,to reduce the processing power and/or data storage requirements of themovable object 102 and/or the control unit 108. For example, thecomputing device 110 is communicatively connected to a database and/orthe computing device 110 includes a database. In some embodiments, thecomputing device 110 is used in lieu of or in addition to the controlunit 108 to perform any of the operations described with regard to thecontrol unit 108.

In some embodiments, the movable object 102 communicates with a controlunit 108 and/or a computing device 110, e.g., via wirelesscommunications 112. In some embodiments, the movable object 102 receivesinformation from the control unit 108 and/or the computing device 110.For example, information received by the movable object 102 includes,e.g., control instructions for controlling parameters of movable object102. In some embodiments, the movable object 102 transmits informationto the control unit 108 and/or the computing device 110. For example,information transmitted by the movable object 102 includes, e.g., imagesand/or video captured by the movable object 102.

In some embodiments, communications between the computing device 110,the control unit 108 and/or the movable object 102 are transmitted via anetwork (e.g., Internet 116) and/or a wireless signal transmitter (e.g.,a long range wireless signal transmitter) such as a cellular tower 118.In some embodiments, a satellite (not shown) is a component of Internet116 and/or is used in addition to or in lieu of the cellular tower 118.

In some embodiments, information communicated between the computingdevice 110, the control unit 108 and/or the movable object 102 includecontrol instructions. Control instructions include, e.g., navigationinstructions for controlling navigational parameters of the movableobject 102 such as position, orientation, attitude, and/or one or moremovement characteristics of the movable object 102, the carrier 104,and/or the payload 106. In some embodiments, control instructionsinclude instructions directing movement of one or more of the movementmechanisms 114. For example, control instructions are used to controlflight of a UAV.

In some embodiments, control instructions include information forcontrolling operations (e.g., movement) of the carrier 104. For example,control instructions are used to control an actuation mechanism of thecarrier 104 so as to cause angular and/or linear movement of the payload106 relative to the movable object 102. In some embodiments, controlinstructions adjust movement of the movable object 102 with up to sixdegrees of freedom.

In some embodiments, control instructions are used to adjust one or moreoperational parameters for the payload 106. For example, controlinstructions include instructions for adjusting an optical parameter(e.g., an optical parameter of an imaging device 302). In someembodiments, control instructions include instructions for adjustingimaging properties and/or image device functions, such as adjusting adistance between an image sensor 304 and an optical device 306,instructions for capturing an image, initiating/ceasing video capture,powering an imaging device 302 on or off, adjusting an imaging mode(e.g., capturing still images or capturing video), adjusting a distancebetween left and right components of a stereographic imaging system,and/or adjusting a position, orientation, and/or movement (e.g., panrate, pan distance) of a carrier 104, a payload 106 and/or an imagingdevice 302.

In some embodiments, when control instructions are received by movableobject 102, the control instructions change parameters of and/or arestored by the memory 204.

FIG. 1B illustrates a movable environment 150, in accordance with someembodiments. In the movable object environment 150, the movable object102 is moved by a movement mechanism 114 that is remote from the movableobject 102, e.g., a person, animal, vehicle, dolly, and/or other movingdevice. For example, the movable object 102 is a device that is handheldand/or wearable. In some embodiments, movable object is coupled (e.g.,via the carrier 104) to a support structure 152 that is handheld and/orwearable.

In some embodiments, a carrier 104 is coupled to the movable object 102.In some embodiments, the carrier 104 includes one or more mechanismsthat allow the movable object 102 to move relative to a movementmechanism 114 and/or relative to the support structure 152. In someembodiments, the movable object 102 is coupled to the support structure152 via a carrier 104 that includes a gimbal.

In some embodiments, the movable object 102 is communicatively coupledto the control unit 108 via a wired and/or wireless connection. In someembodiments, information transmitted from the control unit 108 tomovable object includes, e.g., control instructions for altering one ormore operating parameters of the movable object 102. For example, themovable object 102 receives control instructions for altering an opticalparameter of an imaging device 302 of the movable object 102. In someembodiments, information transmitted from the movable object 102 to thecontrol unit 108 includes, e.g., image and/or video data captured bymovable object 102.

FIG. 2A illustrates an exemplary movable object 102 in a movable objectenvironment 100, in accordance with some embodiments. The movable object102 typically includes one or more processing units 202, a memory 204, acommunication system 206, a movable object sensing system 210, and acommunication bus 208 for interconnecting these components.

In some embodiments, the movable object 102 is a UAV and includescomponents to enable flight and/or flight control. In some embodiments,the movable object 102 includes the communication system 206 with one ormore network or other communications interfaces, the movement mechanisms114, and/or the movable object actuators 212, which are optionallyinterconnected with one or more other components of the movable object102 via the communication bus 208. Although the movable object 102 isdepicted as an aircraft, this depiction is not intended to be limiting,and any suitable type of movable object can be used.

In some embodiments, the movable object 102 includes movement mechanisms114 (e.g., propulsion mechanisms). Although the plural term “movementmechanisms” is used herein for convenience of reference, “movementmechanisms 114” refers to a single movement mechanism (e.g., a singlepropeller) or multiple movement mechanisms (e.g., multiple rotors). Themovement mechanisms 114 include one or more movement mechanism typessuch as rotors, propellers, blades, engines, motors, wheels, axles,magnets, nozzles, and so on. The movement mechanisms 114 are coupled tomovable object 102 at, e.g., the top, bottom, front, back, and/or sides.In some embodiments, the movement mechanisms 114 of a single movableobject 102 include multiple movement mechanisms of the same type. Insome embodiments, the movement mechanisms 114 of a single movable object102 include multiple movement mechanisms with different movementmechanism types. The movement mechanisms 114 are coupled to movableobject 102 (or vice-versa) using any suitable means, such as supportelements (e.g., drive shafts) and/or other actuating elements (e.g., themovable object actuators 212). For example, a movable object actuator212 receives control signals from the processor(s) 202 (e.g., via thecontrol bus 208) that activates the movable object actuator 212 to causemovement of a movement mechanism 114. For example, the processor(s) 202include an electronic speed controller that provides control signals toa movable object actuator 212.

In some embodiments, the movement mechanisms 114 enable the movableobject 102 to take off vertically from a surface or land vertically on asurface without requiring any horizontal movement of the movable object102 (e.g., without traveling down a runway). In some embodiments, themovement mechanisms 114 are operable to permit the movable object 102 tohover in the air at a specified position and/or orientation. In someembodiments, one or more of the movement mechanisms 114 are controllableindependently of one or more of the other movement mechanisms 114. Forexample, when the movable object 102 is a quadcopter, each rotor of thequadcopter is controllable independently of the other rotors of thequadcopter. In some embodiments, multiple movement mechanisms 114 areconfigured for simultaneous movement.

In some embodiments, the movement mechanisms 114 include multiple rotorsthat provide lift and/or thrust to the movable object 102. The multiplerotors are actuated to provide, e.g., vertical takeoff, verticallanding, and hovering capabilities to the movable object 102. In someembodiments, one or more of the rotors spin in a clockwise direction,while one or more of the rotors spin in a counterclockwise direction.For example, the number of clockwise rotors is equal to the number ofcounterclockwise rotors. In some embodiments, the rotation rate of eachof the rotors is independently variable, e.g., for controlling the liftand/or thrust produced by each rotor, and thereby adjusting the spatialdisposition, velocity, and/or acceleration of the movable object 102(e.g., with respect to up to three degrees of translation and/or up tothree degrees of rotation).

In some embodiments, the memory 204 stores one or more programs (e.g.,sets of instructions), modules, and/or data structures. One or moreelements described with regard to the memory 204 are optionally storedby the control unit 108, the computing device 110, and/or anotherdevice. In some embodiments, imaging device 302 includes memory thatstores one or more parameters described with regard to the memory 204.

In some embodiments, the memory 204 stores a system configuration thatincludes one or more system settings (e.g., as configured by amanufacturer, administrator, and/or user). For example, identifyinginformation for the movable object 102 is stored as a system setting ofthe system configuration. In some embodiments, the system configurationincludes an imaging device configuration. The imaging deviceconfiguration stores parameters for the optical device 306 such asinitial position, initial step size, zoom level and/or focus parameters(e.g., amount of focus, selecting autofocus or manual focus, and/oradjusting an autofocus target in an image). Imaging property parametersstored by the imaging device configuration include, e.g., imageresolution, image size (e.g., image width and/or height), aspect ratio,pixel count, quality, focus distance, depth of field, exposure time,shutter speed, and/or white balance. In some embodiments, parametersstored by the imaging device configuration are updated in response tocontrol instructions (e.g., received by the movable object 102 fromcontrol unit 108 and/or the computing device 110). In some embodiments,parameters stored by the imaging device configuration are updated inresponse to information received from the movable object sensing system210 and/or the imaging device 302.

In some embodiments, the memory 204 includes an imaging deviceadjustment module. The imaging device adjustment module stores, e.g.,instructions for adjusting a distance between an image sensor 304 and anoptical device 306 of an imaging device 302.

The above identified modules or programs (i.e., sets of instructions)need not be implemented as separate software programs, procedures ormodules, and thus various subsets of these modules may be combined orotherwise re-arranged in various embodiments. In some embodiments, thememory 204 may store a subset of the modules and data structuresidentified above. Furthermore, the memory 204 may store additionalmodules and data structures not described above. In some embodiments,the programs, modules, and data structures stored in the memory 204, ora non-transitory computer readable storage medium of memory 204, provideinstructions for implementing respective operations in the methodsdescribed below. In some embodiments, some or all of these modules maybe implemented with specialized hardware circuits that subsume part orall of the module functionality. One or more of the above identifiedelements may be executed by one or more processors 202 of the movableobject 102. In some embodiments, one or more of the above identifiedelements is executed by one or more processors of a device remote fromthe movable object 102, such as processor(s) of control unit 108 and/orprocessor(s) of computing device 110.

The communication system 206 enables communication with the control unit108 and/or the computing device 110, e.g., via wireless signals 112. Thecommunication system 206 includes, e.g., transmitters, receivers, and/ortransceivers for wireless communication. In some embodiments, thecommunication is one-way communication, such that data is only receivedby the movable object 102 from the control unit 108 and/or the computingdevice 110, or vice-versa. In some embodiments, communication is two-waycommunication, such that data is transmitted in both directions betweenthe movable object 102 and the control unit 108 and/or the computingdevice 110. In some embodiments, the movable object 102, the controlunit 108, and/or the computing device 110 are connected to the Internet116 or other telecommunications network, e.g., such that data generatedby the movable object 102, the control unit 108, and/or the computingdevice 110 is transmitted to a server for data storage and/or dataretrieval (e.g., for display by a website).

In some embodiments, the sensing system 210 of the movable object 102includes one or more sensors. In some embodiments, one or more sensorsof the movable object sensing system 210 are mounted to the exterior,located within, or otherwise coupled to the movable object 102. In someembodiments, one or more sensors of the movable object sensing system210 are components of the carrier 104, the payload 106, and or theimaging device 302. Where sensing operations are described herein asbeing performed by the movable object sensing system 210, it will berecognized that such operations are optionally performed by one or moresensors of the carrier 104, the payload 106, and or the imaging device302 in addition to or in lieu of one or more sensors of the movableobject sensing system 210.

The movable object sensing system 210 generates static sensing data(e.g., a single image captured in response to a received instruction)and/or dynamic sensing data (e.g., a series of images captured at aperiodic rate, such as a video).

In some embodiments, the movable object sensing system 210 includes animage sensor 304. For example, the movable object sensing system 210includes an image sensor 304 that is a component of an imaging device302, such as a camera (FIG. 3). In some embodiments, the movable objectsensing system 210 includes multiple image sensors, such as a pair ofimage sensors for stereographic imaging (e.g., a left stereographicimage sensor and a right stereographic image sensor).

In some embodiments, the movable object sensing system 210 includes oneor more audio transducers. For example, an audio detection systemincludes an audio output transducer (e.g., a speaker) and/or an audioinput transducer (e.g., a microphone, such as a parabolic microphone).In some embodiments, microphone and a speaker are used as components ofa sonar system. A sonar system is used, for example, to provide athree-dimensional map of the surroundings of the movable object 102.

In some embodiments, the movable object sensing system 210 includes oneor more infrared sensors. In some embodiments, a distance measurementsystem for measuring a distance from the movable object 102 to an objector surface includes one or more infrared sensors, such a left infraredsensor and a right infrared sensor for stereoscopic imaging and/ordistance determination.

In some embodiments, the movable object sensing system 210 includes oneor more global positioning system (GPS) sensors, motion sensors (e.g.,accelerometers), rotation sensors (e.g., gyroscopes), inertial sensors,proximity sensors (e.g., infrared sensors) and/or weather sensors (e.g.,pressure sensor, temperature sensor, moisture sensor, and/or windsensor).

In some embodiments, sensing data generated by one or more sensors ofthe movable object sensing system 210 and/or information determinedusing sensing data from one or more sensors of the movable objectsensing system 210 is used as a depth sensor for depth detection, e.g.,the image sensor, the audio sensor, and/or the infrared sensor are usedto determine a distance from the movable object 102 to another object,such as a target, an obstacle, and/or terrain.

In some embodiments, sensing data generated by one or more sensors ofthe movable object sensing system 210 and/or information determinedusing sensing data from one or more sensors of the movable objectsensing system 210 are transmitted to the control unit 108 and/or thecomputing device 110 (e.g., via the communication system 206). In someembodiments, data generated by one or more sensors of the movable objectsensing system 210 and/or information determined using sensing data fromone or more sensors of the movable object sensing system 210 is storedby the memory 204.

In some embodiments, the movable object 102, the control unit 108,and/or the computing device 110 use sensing data generated by sensors ofthe sensing system 210 to determine information such as a position ofthe movable object 102, an orientation of the movable object 102,movement characteristics of the movable object 102 (e.g., angularvelocity, angular acceleration, translational velocity, translationalacceleration and/or direction of motion along one or more axes), and/orproximity of the movable object 102 to potential obstacles, targets,weather conditions, locations of geographical features and/or locationsof manmade structures.

FIG. 2B illustrates an exemplary movable object 102 in a movable objectenvironment 150, in accordance with some embodiments. A movable object102 in the movable object environment 150 is moved by a movementmechanism 114 that is remote from the movable object 102 (e.g., asdescribed with regard to FIG. 1B). The movable object 102 of the movableobject environment 150 includes, e.g., one or more processing units 202,a memory 204, a sensing system 210, and/or a communication bus 208 forinterconnecting these components. In some embodiments, the movableobject 102 is communicatively coupled to a control unit 108, e.g., via acommunication system 206.

FIG. 3 illustrates an exemplary sensing system 210 of the movable object102, in accordance with some embodiments. In some embodiments, themovable object sensing system 210 includes an imaging device 302 (e.g.,a camera). In some embodiments, the imaging device 302 is a component ofthe payload 106. The imaging device 302 includes an image sensor 304 andan optical device 306. In some embodiments, the optical device 306 ismoved relative to the imaging device 302 by an imaging device actuator308.

The image sensor 304 is, e.g., a sensor that detects light, such asvisible light, infrared light, and/or ultraviolet light. In someembodiments, the image sensor 304 includes, e.g., semiconductorcharge-coupled devices (CCD), active pixel sensors using complementarymetal-oxide-semiconductor (CMOS) and/or N-typemetal-oxide-semiconductors (NMOS, Live MOS).

The optical device 306 affects the focus of light that arrives at theimage sensor 304. For example, the optical device 306 is a lens or adevice including multiple lenses (e.g., a compound lens). A lens is,e.g., a material having curved surfaces that give rise to lensproperties, such as causing light rays to converge (e.g., at a focallength) and/or diverge.

The imaging device actuator 308 is, e.g., a motor, such as a hydraulic,pneumatic, electric, thermal, magnetic, and/or mechanical motor. In someembodiments, imaging device actuator 308 translates an optical device306 along one or more axes relative to the image sensor 304 of theimaging device 302. In some embodiments, the imaging device actuator 308moves the optical device 306 in response to optical control instructionsreceived from a processor (e.g., processor(s) 202). For example, theimaging device actuator 308 moves the optical device 306 in response tooptical control instructions generated in response to user input (e.g.,user input received via an input device of the control unit 108 toinitiate an image capture and/or autofocus process).

FIG. 4 is a cross sectional view of an exemplary imaging device 302, inaccordance with some embodiments. In some embodiments, the imagingdevice 302 includes a camera body 402. The camera body 402 is, e.g., abody of the movable object 102, a body mounted on and/or inside of themovable object 102, a body coupled to the carrier 104 (e.g., as apayload 106), and/or a body coupled to a payload 106. The camera body402 is, e.g., a structure to which an image sensor 304 is coupled. Thecamera body 402 includes a camera body opening that admits light intothe camera body 402. In some embodiments, the camera body 402 isfabricated from a material that reduces or eliminates light penetrationsuch that the camera body 402 admits light only at the camera bodyopening (e.g., via the optical device 306 and/or the camera lens 404).In some embodiments, the optical device 306 and/or the camera lens 404is mounted over an opening of camera body 402.

In some embodiments, an optical device 306 is coupled (e.g., fixedly,movably, and/or interchangeably mounted) to camera body 402. Although inFIG. 4 the optical device 306 is depicted as a single lens that movesrelative to the camera body 402, in some embodiments, the optical device306 is a camera lens 404 (e.g., an optical device that is fixedly and/ordetachably mounted to the camera body 402) that includes one or moreoptical elements (e.g., lenses) that move relative to the image sensor304. In some embodiments, the optical device 306 is mounted on theinterior of the camera body 402.

The optical device 306 moves relative to the image sensor 304 along anx-axis. In FIG. 4, the optical device 306 is shown (with dotted linesindicating past positions of the optical device 306) at a first positionx₀ that is at a first separation distance between the optical device 306and the image sensor 304, a second position x₁ that is at a secondseparation distance between optical device 306 and the image sensor 304,and a third position x₂ that is at a third separation distance betweenthe optical device 306 and the image sensor 304. Optical device 306 isshown (with solid lines indicating a current position of the opticaldevice 306) at a fourth position x₃ that is at a fourth separationdistance between the optical device 306 and the image sensor 304. Insome embodiments, during an autofocus operation, a first image iscaptured at first position x₀, a second image is captured at secondposition x₁, a third image is captured at third position x₂, a fourthimage is captured at fourth position x₃, and so on.

In some embodiments, the optical device 306 is moved relative to theimage sensor 304 to focus an image captured by the image sensor 304. Forexample, the optical device 306 is moved relative to the image sensor304 during an autofocus operation. In some embodiments, the autofocusoperation is a contrast detection autofocus operation. The contrastdetection autofocus operation includes, e.g., determining a contrastvariation rate for an image captured by the image sensor 304. As thecontrast variation rate increases, the focus of the image captured bythe image sensor 304 improves. During the autofocus operation, when theoptical device 306 is moved relative to the image sensor 304, a contrastvariation rate is determined (e.g., based on an image captured by theimage sensor 304 and at least one previous captured image). Inaccordance with some embodiments as described below, the contrastvariation rate is used to determine a step size for approaching aseparation distance between the image sensor 304 and the optical device306 at which the image is focused. In some embodiments, by determining anew step size after capturing a new image during the autofocus process,autofocus can be achieved by gradually approaching a focus separationdistance (e.g., an estimated separation distance between the imagesensor 304 and the optical device 306 at which focus is achieved,substantially achieved, and/or maximized). The new step size is, e.g.,an increased step size (e.g., when the current separation distance isrelatively far from the focus separation distance) or a decreased stepsize (e.g., when the current separation is relatively close to the focusseparation distance). In some embodiments, the focus of the imagecaptured by the image sensor 304 is iteratively improved such that thefocus separation distance is approached and/or reached without the needto overshoot the focus separation distance. In this way, movement ofcomponents of the movable object 102, such as the optical device 306and/or the image sensor 304, is reduced in comparison with autofocustechniques that rely on less precise movements and/or overshoot of afocus separation distance.

FIG. 5 illustrates contrast variation determination for an exemplaryimage 502 captured by the image sensor 304, in accordance with someembodiments. In some embodiments, a contrast gradient is captured acrossone or more portions of the image 502. A portion of the image 502 is,e.g., a subset of pixels of the image 502, such as a 16×16 array ofpixels or a 4×4 array of pixels. In some embodiments, an image isdivided into four quadrants and subsets of pixels are selected from oneor more quadrants of the image. For example, the image 502 includessubsets of pixels 504, 506, 508, and 510 corresponding to quadrants 514,516, 518 and 520, respectively, of the image 502.

The pixel array 512 illustrates a 4×4 array of pixels corresponding tothe subset of pixels 510. The pixel array 512 includes pixels with avariety of luminance values. For example, the pixel 522 has a lowluminance value relative to the pixel 524. A luminance gradient acrossthe pixels of the pixel array 512 is determined based on a variation inluminance across the pixel array 512. For example, a luminance gradientvalue for the pixel subset 510 is determined as follows:

$\begin{matrix}\frac{\begin{matrix}{{{Highest}\mspace{14mu} {luminance}\mspace{14mu} {value}\mspace{14mu} {for}\mspace{14mu} {pixel}\mspace{14mu} {array}} -} \\{{lowest}\mspace{14mu} {luminance}\mspace{14mu} {value}\mspace{14mu} {for}\mspace{14mu} {pixel}\mspace{14mu} {array}}\end{matrix}}{{number}\mspace{14mu} {of}\mspace{14mu} {pixels}\mspace{14mu} {in}\mspace{14mu} {pixel}\mspace{14mu} {array}} & (1)\end{matrix}$

In some embodiments, determining a contrast value for the image 502includes determining an average of luminance gradients for the pixelsubsets 504, 506, 508, and 510. For example, a contrast value for theimage 502 is determined as follows:

$\begin{matrix}\frac{\begin{matrix}{\sum{\mspace{11mu} \;}{{luminance}\mspace{14mu} {gradients}{\mspace{11mu} \;}{for}{\mspace{11mu} \;}{pixel}}} \\{{subsets}{\mspace{11mu} \;}{in}\mspace{14mu} {image}}\end{matrix}}{{number}\mspace{14mu} {of}\mspace{14mu} {pixel}\mspace{14mu} {subsets}\mspace{14mu} {in}\mspace{14mu} {image}} & (2)\end{matrix}$

In some embodiments, a contrast value is determined using a pixel subsetat a position corresponding to a location in the image 502 designated bya user (e.g., designated by input provided via the control unit 108and/or the computing device 110). In some embodiments, a contrast valueis determined using a pixel subset at a position corresponding to atarget or a portion of a target being tracked by the movable object 102as captured in the image 502 (e.g., a target designated by inputprovided via the control unit 108 and/or the computing device 110). Insome embodiments, a contrast value is determined using luminance valuesof all pixels of the image 502.

FIGS. 6A-6C illustrate a simplified representation of locations at whichlight rays corresponding to the object 602 converge based on variousseparation distances between the optical device 306 and the image sensor304, in accordance with some embodiments. FIGS. 6D-6F illustratecontrast distributions corresponding to the respective separationdistances illustrated in FIGS. 6A-6C, in accordance with someembodiments. FIGS. 6G-6I illustrate pixel arrays corresponding to therespective separation distances illustrated in FIGS. 6A-6C, inaccordance with some embodiments.

Typically, an image is in focus when the contrast value in the image ismaximized. In some embodiments, an autofocus operation that usescontrast value determination includes iteratively adjusting a separationdistance between the optical device 306 and the image sensor 304 as acontrast value reaches a maximum value.

In FIGS. 6A and 6C, an image 502 of an object 602 captured by the imagesensor 304 is out of focus. In FIG. 6A, light rays 604 corresponding tothe object 602 converge at a position 606 in front of the image sensor304 (e.g., to the right of the image sensor 304 as illustrated in FIG.6A). In FIG. 6C, light rays 602 converge at a position 608 behind theimage sensor 304 (e.g., to the left of the image sensor 304 asillustrated in FIG. 6C). In FIG. 6B, an image 502 captured by the imagesensor 304 is in focus because light rays 604 converge at a positioncorresponding to the position of the image sensor 304.

FIG. 6D illustrates a contrast distribution 612 across a portion of animage 502 (e.g., at a pixel array 512). The contrast distribution 612 ofFIG. 6D corresponds to the separation distance of the optical device 306and the image sensor 304 shown in FIG. 6A. FIG. 6E illustrates acontrast distribution 614 across a portion of an image 502 captured whenthe separation distance of the optical device 306 and the image sensor304 are as shown in FIG. 6B. FIG. 6F illustrates a contrast distribution616 across a portion of an image 502 captured when the separationdistance of the optical device 306 and the image sensor 304 is as shownin FIG. 6C.

FIG. 6G illustrates a subset of pixels 618 from an image 502 captured bythe image sensor 304, corresponding to the separation distance of theoptical device 306 and the image sensor 304 shown in FIG. 6A. FIG. 6Hillustrates a subset of pixels 620 from an image captured by the imagesensor 304, corresponding to the separation distance of the opticaldevice 306 and the image sensor 304 shown in FIG. 6B. FIG. 6Iillustrates a subset of pixels 622 from an image captured by the imagesensor 304, corresponding to the separation distance of the opticaldevice 306 and the image sensor 304 shown in FIG. 6C. Compared withcontrast values of the pixel array 622 and the pixel array 618, thecontrast value of the pixel array 620 is high, demonstrating that thedifference between the highest-luminance pixels and lowest-luminancepixels increases as focus improves. This is also demonstrated by thesteepness of the slope of the contrast distribution 614 relative tocontrast distributions 612 and 616.

FIG. 7 illustrates contrast values y₀, y₁, y₂, and y₃ obtained fromimages captured at separation distances x₀, x₁, x₂, and x₃,respectively, between the optical device 306 and the image sensor 304.For example, separation distances x₀, x₁, x₂, and x₃ of FIG. 7 areseparation distances x₀, x₁, x₂, and x₃, described with regard to FIG.4.

In some embodiments, a curve is generated based on determined contrastvalues y₀, y₁, y₂, and y₃. For example, a generated curve is used toestimate a peak contrast value (e.g., an estimated contrast valuey_(peak) corresponding to a focus separation distance x_(peak) betweenthe optical device 306 and the image sensor 304. In some embodiments,the generated curve is a Bézier curve, such as a cubic Bézier curve. Forexample, a generated cubic Bézier curve is determined for (x₀, y₀), (x₁,y₁), (x₂, y₂), (x₃, y₃) as follows:

$\begin{matrix}{{Cubic}\mspace{14mu} B\overset{'}{e}{zier}{\mspace{11mu} \;}{curve}\text{:}\mspace{14mu} \left\{ \begin{matrix}\begin{matrix}{{y(t)} = {{y_{0}\left( {1 - t} \right)}^{3} + {3y_{1}{t\left( {1 - t} \right)}^{2}} +}} \\{{3y_{2}{t^{2}\left( {1 - t} \right)}} + {y_{3}t^{3}}}\end{matrix} \\\begin{matrix}{{x(t)} = {{x_{0}\left( {1 - t} \right)}^{3} + {3x_{1}{t\left( {1 - t} \right)}^{2}} +}} \\{{3x_{2}{t^{2}\left( {1 - t} \right)}} + {x_{3}t^{3}}}\end{matrix}\end{matrix} \right.} & (3)\end{matrix}$

In some embodiments, e.g., after the separation distance between theoptical device 306 and the image sensor 304 is increased by a next stepvalue s_(n) such that a contrast value y_(n) is determined at aseparation distance x_(n) between the optical device 306 and the imagesensor 304, a nonlinear least squares analysis is used to find a bestfit curve to (x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃, y₃) . . . (x_(n),y_(n)).

FIG. 8A illustrates a cubic Bézier curve 802 determined for (x₀, y₀),(x₁, y₁), (x₂, y₂), (x₃, y₃). An estimated point at which the contrastvalue is at a maximum y_(peak) (the peak of the curve) corresponds to apoint at which the derivative of the curve 802 is equal to zero. Toobtain y_(peak), the value t_(peak) (e.g., the value oft when y′(t) ofthe cubic Bézier curve is equal to zero) is determined:

−3t _(peak) ²(y ₀−3y ₁+3y ₂ −y ₃)+6t _(peak)(y ₀−2y ₁ +y ₂)−3(y ₀ −y₁)=0   (4)

To obtain x_(peak), the determined value of t from (4) is used in (5):

x(t _(peak))=x ₀(1−t _(peak))³+3x ₁ t _(peak)(1−t _(peak))²+3x ₂ t_(peak) ²(1−t _(peak))+x ₃ t _(peak) ³   (5)

FIG. 8B illustrates determined values (x_(peak), y_(peak)) correspondingto an estimated focus separation distance between the optical device 306and the image sensor 304, in accordance with some embodiments.

In some embodiments, the determined x_(peak) value is used fordetermining an increased next step value s_(n), as indicated below:

$\begin{matrix}{{{Increased}\mspace{14mu} {step}\mspace{14mu} {size}\text{:}\mspace{14mu} s_{n}} = {\frac{1 + \left( {x_{peak} - x_{c}} \right)}{{total}\mspace{14mu} {length}}\left( {x_{3} - x_{2}} \right)}} & (6)\end{matrix}$

The value of “total length” in equation (6) is, for example, a maximumseparation distance between the optical device 306 and the image sensor304 (e.g., as constrained by the camera body 402 and/or the camera lens404) A current separation distance between the optical device 306 andthe image sensor 304 is indicated by x_(c).

In some embodiments, when next step value s_(n) has been determined, theseparation distance between the optical device 306 and the image sensor304 is increased from x_(c) by the value s_(n), such that the distancebetween the optical device 306 and the image sensor 304 is increased tox_(n) (e.g., as shown in FIG. 8C). In some embodiments, when theseparation distance between the optical device 306 and the image sensor304 has been increased to a next distance x_(n), an image 502 iscaptured and a next contrast value y_(n) is determined.

FIG. 8C illustrates a contrast value y_(n) determined after the distancebetween the optical device 306 and the image sensor 304 has beenincreased to a distance x_(n).

In some embodiments, when a contrast value y_(n) has been determined, acontrast variation rate 804 (e.g., dy/dx) is determined at the pointx_(n). For example, the contrast variation rate 804 is determined asfollows:

$\begin{matrix}{\frac{dy}{dx} = \frac{y_{n} - y_{previous}}{x_{n} - x_{previous}}} & (7)\end{matrix}$

In the illustrative example of FIG. 8C, x_(previous) is x₃ andy_(previous) is y₃.

In some embodiments, when a contrast variation rate has been determined,the contrast variation rate is compared with one or more thresholdvalues. For example, a contrast variation rate is compared with a firstthreshold value (e.g., threshold A) to determine whether a next stepsize will be an increased step size or a decreased step size. Inaccordance with a determination that the contrast variation rate meets afirst threshold criterion (e.g., the contrast variation rate is greaterthan threshold A), the next step size will be an increased step size. Inaccordance with a determination that the contrast variation rate doesnot meet the first threshold criterion (e.g., the contrast variationrate is less than or equal to threshold A), if a next step will betaken, the next step size will be an decreased step size determined asfollows:

$\begin{matrix}{{{Decresed}\mspace{14mu} {step}\mspace{14mu} {size}\text{:}\mspace{14mu} s_{n}} = {\frac{1 - \left( {x_{peak} - x_{c}} \right)}{{total}\mspace{14mu} {length}}\left( {x_{3} - x_{2}} \right)}} & (8)\end{matrix}$

FIG. 8D illustrates various threshold values to which determinedcontrast variation rates are compared, in accordance with variousembodiments. A first threshold 806 (e.g., threshold A) has a firstgradient (e.g., slope value), a second threshold 808 (e.g., threshold B)has a second gradient, and a third threshold 810 has a third gradient.In some embodiments, the absolute value of the gradient of threshold Bis lower than the absolute value of the gradient of threshold A and theabsolute value of the gradient of threshold C is lower than the absolutevalue of the gradient of threshold C.

In some embodiments, the contrast variation rate 804 as shown in FIG. 8Cis compared with the first threshold 806 as shown in FIG. 8D. Inaccordance with a determination that the contrast variation rate 804(e.g., the dy/dx value of 804) is greater than (steeper than) the firstthreshold 806 (threshold A) slope value, the next step size will be anincreased step size determined using (6). In accordance with adetermination that the contrast variation rate 804 (e.g., the dy/dxvalue of 804) is less than or equal to (e.g., as steep or less steepthan) the first threshold 806 (threshold A) slope value, the contrastvariation rate 804 is compared with the second threshold 808 (thresholdB) slope value. In accordance with a determination that the contrastvariation rate 804 (e.g., the dy/dx value of 804) is greater than(steeper than) the second threshold 808 (threshold B) slope value, thenext step size will be a decreased step size determined using (8).

In accordance with a determination that the contrast variation rate 804(e.g., the dy/dx value of 804) is less than or equal to (e.g., as steepor less steep than) the second threshold 808 (threshold B) slope value,a low pass filter is applied to (x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃, y₃) .. . (x_(n), y_(n)) to obtain a filtered contrast distribution, and agradient of the filtered contrast distribution is determined at thepoint x_(n) as follows:

$\begin{matrix}{\frac{dy}{dx} = \frac{y_{n} - y_{previous}}{x_{n} - x_{previous}}} & (9)\end{matrix}$

In some embodiments, the gradient of the filtered contrast distributionis compared with the third threshold 810 (threshold C) slope value. Inaccordance with a determination that the gradient of the filteredcontrast distribution is greater than (steeper than) the third threshold810 (threshold C) slope value, one or more of the operations describedwith regard to FIGS. 4-8D are repeated. In accordance with adetermination that the gradient of the filtered contrast distribution isless than or equal to (e.g., as steep or less steep than) the thirdthreshold 810 (threshold C) slope value, it is determined that the focusseparation distance has been achieved.

FIGS. 9A-9C are a flow diagram illustrating a method 900 for moving anoptical device relative to an image sensor to focus an image, inaccordance with some embodiments. The method 900 is performed at adevice, such as the movable object 102, the imaging device 302, thecontrol unit 108 and/or the computing device 110. For example,instructions for performing the method 900 are stored in the memory 204and executed by processor(s) 202.

In some embodiments, the device determines (902) whether the opticaldevice 306 is at an initial position (e.g., a position x₀ at which aseparation distance between the optical device 306 and the image sensor304 is x₀). In accordance with a determination that optical device 306is at an initial position, the device captures (906) an image 502 viathe image sensor 304. In accordance with a determination that theoptical device 306 is not at the initial position, the device providesinstructions to the imaging device actuator 308 to move (908) theoptical device 306 to the initial position. The device determines (910)an initial contrast value (e.g., y₀) at the initial position. Forexample, initial contrast value y₀ is determined in accordance withequations (1)-(2) above.

The device provides instructions to the imaging device actuator 308 tomove (912) the optical device 306 to a second position (next position,e.g., a position x₁ at which a separation distance between the opticaldevice 306 and the image sensor 304 is x₁). The device captures (914) asecond image (next image) 502 via image sensor 304 when optical device306 is at the second position. The device determines (916) a contrastvalue (e.g., y₁) at the second position. For example, second contrastvalue (next contrast value) y₁ is determined in accordance withequations (1)-(2) above.

In some embodiments, the device provides instructions to imaging deviceactuator 308 to move (918) the optical device 306 to a next position(e.g., a position x_(i) at which a separation distance between theoptical device 306 and the image sensor 304 is x_(i)). For example, in afirst iteration, i=2, and the position x_(i) is x₂. The device captures(920) a next image 502 via image sensor 304 when optical device 306 isat the next position x_(i). The device determines (922) a next contrastvalue (e.g., y_(i)) at the next position. For example, contrast valuey_(i) is determined in accordance with equations (1)-(2) above.

In some embodiments, the device determines (924) whether the number ofpositions (i) has reached a target number positions (e.g., a predefinedtarget number of positions). For example, when four contrast values y₀,y₁, y₂, y₃ are needed to perform the calculation indicated at equation(3), i=3. In some embodiments, in accordance with a determination that ihas not reached 3, the device (926) increments i (e.g., the device setsthe value of i to be i+1). Operations 918, 920, 922, 924, and/or 926 arerepeated until the device determines that the number of positions (i)has reached a target number positions (e.g. i=3). In accordance with adetermination that the number of positions has reached the target numberof positions (e.g., contrast values y₀, y₁, y₂, y₃ have been obtained),the device generates (928) a curve. For example, the device generates acubic Bézier curve (e.g., 802) as indicated at equation (3).

As indicated at A, the device proceeds from operation 928 of FIG. 9A tooperation 930 of FIG. 9B.

To determine a separation distance x_(peak) between the image sensor 304and the optical device 306 at which an estimated peak contrast valuey_(peak) occurs (e.g., as described with reference to FIGS. 8A-8B), thedevice determines (930) a peak value t_(peak) e.g., using equation (4).The device determines (932) a distance x_(peak) based on t_(peak), e.g.,using equation (5). The device determines (934) a next step size s_(n),e.g., using equation (6) for an increased next step size or, (e.g., inlater iterations and/or in accordance with a determination to use adecreased step size), using equation (8) for a decreased next step size.The device provides instructions to the imaging device actuator 308 tomove (936) the optical device 306 from a current position x_(c) to anext position (e.g., a position x_(n) at which a separation distancebetween the optical device 306 and the image sensor 304 isx_(n)=x_(c)+s_(n).

The device captures (938) a next image 502 when the separation distancebetween the optical device 306 and the image sensor 304 is x_(n). Thedevice determines (940) a next contrast value (e.g., y_(n)) at the nextposition. For example, contrast value y_(n) is determined in accordancewith equations (1)-(2) above. The device determines (942) a contrastvariation rate (e.g., as indicated at 804) at position x_(n). Forexample, a contrast variation rate dy/dx is determined in accordancewith equation (7) above. The device compares (944) the contrastvariation rate determined at (942) with a threshold A (806).

As indicated at B, the device proceeds from operation 944 of FIG. 9B todecision diamond 946 of FIG. 9C.

The device determines (946) whether the contrast variation rate (e.g.,804) exceeds the threshold A 806 gradient value. In accordance with adetermination that the contrast variation rate exceeds the threshold Agradient value, the device (948) will determine the next step size s_(n)(e.g., at an next iteration of the operation 934) using increased nextstep size equation (6). In accordance with a determination that thecontrast variation rate does not exceed the threshold A slope value, thedevice determines (950) whether the contrast variation rate (e.g., 804)exceeds the gradient of the threshold B 808. In accordance with adetermination that the contrast variation rate exceeds the threshold Bgradient value, the device (952) will determine the next step size s_(n)(e.g., at an next iteration of the operation 934) using decreased nextstep size equation (8).

As indicated at C, the device proceeds from operations 948 and/or 952 ofFIG. 9C to the operation 954 of FIG. 9B. At the operation 954, thedevice generates a new curve using x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃, y₃). . . (x_(n), y_(n)). For example, a nonlinear least squares analysis isused to find a best fit curve to (x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃, y₃). . . (x_(n), y_(n)). Operations 930, 932, 934, 936, 938, 940, 942, 944,946, 948, 950, 952, and/or 954 repeat until the device determines thatthe contrast variation rate does not exceed the gradient of threshold Bslope value.

In accordance with a determination that the contrast variation rate doesnot exceed the threshold B slope value, the device applies (956) a lowpass filter to (x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃, y₃) . . . (x_(n),y_(n)) to obtain a filtered contrast distribution. The device determines(958) a gradient value dy/dx of the filtered contrast distribution,e.g., using equation (9) at the most recent position of the opticaldevice 306 relative to the image sensor 304 (e.g., at x_(n)). The devicecompares (960) the determined gradient value dy/dx of the filteredcontrast distribution at the position x_(n) to threshold C (810). Insome embodiments, in accordance with a determination that the determinedgradient value dy/dx of the filtered contrast distribution exceeds thethreshold C gradient value, the device proceeds to operation 902 of FIG.9A, as indicated at D. In some embodiments, in accordance with adetermination that the determined gradient value dy/dx of the filteredcontrast distribution does not exceed the threshold C gradient value,the focus separation distance is determined to have been reached and theflow ends.

FIGS. 10A and 10B illustrate exemplary contrast distributions over arange from a minimum separation distance xmin between the optical device306 and the image sensor 304 to a maximum separation distance xmaxbetween the optical device 306 and the image sensor 304. FIG. 10Aillustrates an example of a contrast distribution obtained in a highcontrast setting and FIG. 10B illustrates an example of a contrastdistribution obtained in a low contrast setting (e.g., a low lightsetting). The presence of noise in a contrast distribution (e.g., asdemonstrated in FIG. 10B, particularly in comparison with FIG. 10A) dueto, e.g., low light conditions, light flicker, and/or movement of theimaging device during the autofocus process, has the potential to reducethe accuracy with which a focus separation distance is determined.Applying a low pass filter to determined contrast values (x₀, y₀), (x₁,y₁), (x₂, y₂), (x₃, y₃) . . . (x_(n), y_(n)) reduces the probability ofinaccuracy in the determination of the focus separation distance due tonoise.

FIGS. 11A-11D are a flow diagram illustrating a method 1100 for movingan optical device 306 relative to an image sensor 304 to focus an image502, in accordance with some embodiments. The method 1100 is performedat a device, such as the movable object 102, the imaging device 302, thecontrol unit 108 and/or the computing device 110. For example,instructions for performing the method 1100 are stored in the memory 204and executed by the processor(s) 202.

The device acquires (1102), by the image sensor 304, a first image(current image) 502 when the optical device 306 is at a first position(current position) relative to the image sensor 304 (e.g., at aseparation distance x_(n) between the optical device 306 and the imagesensor 304). The device obtains (1104) a first contrast value (currentcontrast value) y_(n) of the first image 502 (e.g., a contrast valuedetermined in accordance with equations (1) and/or (2)) and a firstcontrast variation rate (current contrast variation rate) dy/dx at thefirst position x_(n) (e.g., a contrast variation rate determined inaccordance with equation (7), such as the contrast variation rateillustrated at 804).

The device determines (1106) whether the first contrast variation ratedy/dx meets a first threshold criterion. For example, the devicedetermines whether the first contrast variation rate dy/dx is greaterthan a first threshold gradient value (e.g., a threshold A gradientvalue as illustrated at 806 of FIG. 8D).

In accordance with a determination that the contrast variation ratemeets the first threshold criterion, the device (1108): determines afirst step size s_(n), the first step size greater than a previous stepsize used for moving the optical device to the first position (e.g.,equation (6) for determining an increased step size is used to determinethe first step size s_(n)); and the device moves the optical device 306from the first position to a second position according to the first stepsize s_(n) (e.g., the optical device 306 is moved to a separationdistance x_(n) from the image sensor 304).

In accordance with a determination that the first contrast variationrate does not meet the first threshold criterion (e.g., the firstcontrast variation rate is less than (or equal to) the first thresholdgradient value, such as a gradient value of threshold A as illustratedat 806 of FIG. 8D), the device (1110): determines a second step sizes_(n), the second step size smaller than the previous step size used formoving the optical device 306 to the first position (e.g., equation (8)for determining an decreased step size is used to determine the secondstep size s_(n)); and the device moves the optical device 306 from thefirst position to the second position according to the second step sizes_(n) (e.g., the optical device 306 is moved to a separation distancex_(n) from the image sensor 304).

The device repeats (1112) the aforementioned operations (e.g., 1102,1104, 1106, 1108, and/or 1110) until a second contrast variation rate(next contrast variation rate) dy/dx meets a second threshold criterion(e.g., the second contrast variation dy/dx is less than (or equal to) asecond threshold gradient value such as threshold B (808)). The secondimage 502 is acquired when the optical device 306 is at the secondposition (separation distance) x_(n+1).

In some embodiments, determining that the first contrast variation ratemeets the first threshold criterion includes (1114) comparing the firstcontrast variation rate to a first threshold gradient value. Forexample, the first threshold gradient value is a gradient valueindicating the slope of the line corresponding to threshold A, as shownat 806 of FIG. 8D.

In some embodiments, the first contrast variation rate meets the firstthreshold criterion when (1116) the first contrast variation rateexceeds a first threshold gradient value. For example, the firstcontrast variation rate meets the first threshold criterion whencontrast variation rate dy/dx as determined in accordance with equation(7) exceeds a gradient value indicating the threshold A gradient value,as shown at 806 of FIG. 8D.

In some embodiments, determining that the second contrast variation ratemeets the second threshold criterion includes (1118) comparing thesecond contrast variation rate to a second threshold gradient value,wherein the second threshold gradient value is less than (e.g., lesssteep than) the first threshold gradient value. For example, the secondcontrast variation rate meets the second threshold criterion whencontrast variation rate dy/dx as determined in accordance with equation(7) exceeds a threshold B gradient value, as shown at 808 of FIG. 8D.

In some embodiments, determining at least one of the first step size andthe second step size includes (1120): generating a curve based on aplurality of contrast values including the first contrast value (e.g.,generating a curve based on y₀, y₁, y₂, y₃, y_(n) as described withregard to 954 of FIG. 9B), determining a position (e.g., separationdistance) of the optical device 306 relative to the image sensor 304 atwhich the curve has a peak value (e.g., determining a position x_(peak),as described with regard to 932) and determining the first step sizes_(n) using the determined position (e.g., x_(peak)) of the opticaldevice 306 relative to the image sensor 304 at which the curve has apeak value. For example, the determined x_(peak) value is used todetermine an increased step size s_(n) as indicated in equation (6).

In some embodiments, in at least one iteration of the repeatingoperation, the curve is a Bézier curve (1122). For example, the Béziercurve is a quadradic or higher-order Bézier curve.

In some embodiments, the Bézier curve is a cubic Bézier curve (1124),e.g., the Bézier curve as defined at (3).

In some embodiments, in at least one iteration of the repeatingoperation, the curve is determined (1126) using a non-linear leastsquares analysis. For example, a non-linear least squares analysis isapplied to find a best fit curve to (x₀, y₀), (x₁, y₁), (x₂, y₂), (x₃,y₃) . . . (x_(n), y_(n)).

In some embodiments, the device determines (1128) the first contrastvalue using at least one luminance gradient value from the first image502, wherein a respective luminance gradient value is a luminancegradient across a portion (e.g., a 4 pixel×4 pixel array 512, or a 16pixel33 16 pixel array) of the first image 502. For example, a contrastvalue is determined in accordance with equations (1) and/or (2) above.

In some embodiments, the device determines (1130) the first contrastvalue using an average of a plurality of luminance gradient values fromthe first image 502 (e.g., four luminance gradient values correspondingto pixel arrays 504, 506, 508, 510 from quadrants 514, 516, 518, 520,respectively, of first image 502), as described with regard to equation(2).

In some embodiments, in response to determining that the second contrastvariation rate meets a second threshold criterion (e.g., the secondcontrast variation rate is less than (or equal to) the slope of secondthreshold B gradient value, as indicated at 808), the device applies(1132) a filter to a plurality of obtained contrast values (x₀, y₀),(x₁, y₁), (x₂, y₂), (x₃, y₃) . . . (x_(n), y_(n)) to generate a filteredcurve.

In some embodiments, the filter (1134) is a low pass filter. In someembodiments, the low pass filter is (1136) a one-dimensional Gaussianfilter.

In some embodiments, the device determines (1138) whether the filteredcurve at the current position of the optical device 306 relative to theimage sensor 304 satisfies an end criterion, and, in response todetermining that the filtered curve does not satisfy the end criterion,the device initializes the optical device 306 at an initial position(e.g., x₀) relative to the image sensor 304 and repeats theaforementioned operations (e.g. repeats operations 1102-1112. In otherwords, the current autofocus attempt is aborted and the autofocusprocess is restarted from the initial position of the optical device 306relative to the image sensor 304 (e.g., separation distance x₀). Forexample, in a target tracking or other video capture context, variousaspects of the captured images, such as the composition and/or lightlevel of captured images, may change rapidly over time, such that if acurrent autofocus attempt fails it is more efficient to restart theautofocus process by collecting new contrast values rather thancontinuing to try to achieve focus based on previously collectedcontrast values.

In some embodiments, determining whether the filtered curve at thecurrent position of the optical device 306 relative to the image sensor304 satisfies the end criterion includes (1140) determining whether agradient of the filtered curve at the current position of the opticaldevice (e.g., as determined using equation 9) relative to the imagesensor meets a third threshold criterion. In some embodiments, thegradient of the filtered curve at the current position of the opticaldevice meets a third threshold criterion when the gradient of thefiltered curve at the current position of the optical device is lessthan (or equal to) a threshold C gradient value (e.g., as indicated at810).

In some embodiments, the second contrast variation rate dy/dx isdetermined (1142) using a second contrast value y_(n+1) obtained for asecond image 502.

In some embodiments, the first contrast variation rate dy/dx is agradient value indicating (1144) a rate of change of a contrast valuefrom a previous image to a current image.

In some embodiments, a contrast variation rate difference is adifference (1146) between the first contrast value y_(n) of the firstimage and a contrast value y_(previous) of a previous image; a distancedifference is a difference between a first distance (current distance)x_(n) between the optical device and the image sensor at which the firstimage is captured and a second distance x_(previous) between the opticaldevice and the image sensor at which the second image is captured; andthe rate of change of the contrast value is the contrast variation ratedifference divided by the distance difference, e.g., as indicated inequation (7).

In some embodiments, initializing the optical device 306 at an initialposition (e.g., x₀) relative to the image sensor 304 includes using datagenerated by a depth sensor of the movable object 102 to determine aninitialization distance. For example, the initial position is determinedbased on output from a depth sensor (e.g., an image sensor, an audiosensor, and/or an infrared sensor) of the movable object sensing system210.

Many features of the present disclosure can be performed in, using, orwith the assistance of hardware, software, firmware, or combinationsthereof. Consequently, features of the present disclosure may beimplemented using a processing system. Exemplary processing systems(e.g., processor(s) 202) include, without limitation, one or moregeneral purpose microprocessors (for example, single or multi-coreprocessors), application-specific integrated circuits,application-specific instruction-set processors, field-programmable gatearrays, graphics processing units, physics processing units, digitalsignal processing units, coprocessors, network processing units, audioprocessing units, encryption processing units, and the like.

Features of the present disclosure can be implemented in, using, or withthe assistance of a computer program product, such as a storage medium(media) or computer readable storage medium (media) having instructionsstored thereon/in which can be used to program a processing system toperform any of the features presented herein. The storage medium (e.g.,the memory 204) can include, but is not limited to, any type of diskincluding floppy disks, optical discs, DVD, CD-ROMs, microdrive, andmagneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, DDRRAMs, flash memory devices, magnetic or optical cards, nanosystems(including molecular memory ICs), or any type of media or devicesuitable for storing instructions and/or data.

Stored on any one of the machine readable medium (media), features ofthe present disclosure can be incorporated in software and/or firmwarefor controlling the hardware of a processing system, and for enabling aprocessing system to interact with other mechanism utilizing the resultsof the present disclosure. Such software or firmware may include, but isnot limited to, application code, device drivers, operating systems, andexecution environments/containers.

Communication systems as referred to herein (e.g., the communicationsystem 206) optionally communicate via wired and/or wirelesscommunication connections. For example, communication systems optionallyreceive and send RF signals, also called electromagnetic signals. RFcircuitry of the communication systems convert electrical signalsto/from electromagnetic signals and communicate with communicationsnetworks and other communications devices via the electromagneticsignals. RF circuitry optionally includes well-known circuitry forperforming these functions, including but not limited to an antennasystem, an RF transceiver, one or more amplifiers, a tuner, one or moreoscillators, a digital signal processor, a CODEC chipset, a subscriberidentity module (SIM) card, memory, and so forth. Communication systemsoptionally communicate with networks, such as the Internet, alsoreferred to as the World Wide Web (WWW), an intranet and/or a wirelessnetwork, such as a cellular telephone network, a wireless local areanetwork (LAN) and/or a metropolitan area network (MAN), and otherdevices by wireless communication. Wireless communication connectionsoptionally use any of a plurality of communications standards, protocolsand technologies, including but not limited to Global System for MobileCommunications (GSM), Enhanced Data GSM Environment (EDGE), high-speeddownlink packet access (HSDPA), high-speed uplink packet access (HSDPA),Evolution, Data-Only (EV-DO), HSPA, HSPA+, Dual-Cell HSPA (DC-HSPDA),long term evolution (LTE), near field communication (NFC), wideband codedivision multiple access (W-CDMA), code division multiple access (CDMA),time division multiple access (TDMA), Bluetooth, Wireless Fidelity(Wi-Fi) (e.g., IEEE 102.11a, IEEE 102.11ac, IEEE 102.11ax, IEEE 102.11b,IEEE 102.11g and/or IEEE 102.11n), voice over Internet Protocol (VoIP),Wi-MAX, a protocol for e-mail (e.g., Internet message access protocol(IMAP) and/or post office protocol (POP)), instant messaging (e.g.,extensible messaging and presence protocol (XMPP), Session InitiationProtocol for Instant Messaging and Presence Leveraging Extensions(SIMPLE), Instant Messaging and Presence Service (IMPS)), and/or ShortMessage Service (SMS), or any other suitable communication protocol,including communication protocols not yet developed as of the filingdate of this document.

While various embodiments of the present disclosure have been describedabove, it should be understood that they have been presented by way ofexample, and not limitation. It will be apparent to persons skilled inthe relevant art that various changes in form and detail can be madetherein without departing from the spirit and scope of the disclosure.

The present disclosure has been described above with the aid offunctional building blocks illustrating the performance of specifiedfunctions and relationships thereof. The boundaries of these functionalbuilding blocks have often been arbitrarily defined herein for theconvenience of the description. Alternate boundaries can be defined solong as the specified functions and relationships thereof areappropriately performed. Any such alternate boundaries are thus withinthe scope and spirit of the disclosure.

The terminology used in the description of the various describedembodiments herein is for the purpose of describing particularembodiments only and is not intended to be limiting. As used in thedescription of the various described embodiments and the appendedclaims, the singular forms “a,” “an,” and “the” are intended to includethe plural forms as well, unless the context clearly indicatesotherwise. It will also be understood that the term “and/or” as usedherein refers to and encompasses any and all possible combinations ofone or more of the associated listed items. It will be furtherunderstood that the terms “includes,” “including,” “comprises,” and/or“comprising,” when used in this specification, specify the presence ofstated features, integers, steps, operations, elements, and/orcomponents, but do not preclude the presence or addition of one or moreother features, integers, steps, operations, elements, components,and/or groups thereof.

As used herein, the term “if” may be construed to mean “when” or “upon”or “in response to determining” or “in accordance with a determination”or “in response to detecting,” that a stated condition precedent istrue, depending on the context. Similarly, the phrase “if it isdetermined [that a stated condition precedent is true]” or “if [a statedcondition precedent is true]” or “when [a stated condition precedent istrue]” may be construed to mean “upon determining” or “in response todetermining” or “in accordance with a determination” or “upon detecting”or “in response to detecting” that the stated condition precedent istrue, depending on the context.

The foregoing description of the present disclosure has been providedfor the purposes of illustration and description. It is not intended tobe exhaustive or to limit the disclosure to the precise forms disclosed.The breadth and scope of the present disclosure should not be limited byany of the above-described exemplary embodiments. Many modifications andvariations will be apparent to the practitioner skilled in the art. Themodifications and variations include any relevant combination of thedisclosed features. The embodiments were chosen and described in orderto best explain the principles of the disclosure and its practicalapplication, thereby enabling others skilled in the art to understandthe disclosure for various embodiments and with various modificationsthat are suited to the particular use contemplated. It is intended thatthe scope of the invention be defined by the following claims and theirequivalence.

What is claimed is:
 1. A method for moving an optical device relative toan image sensor to focus an image, comprising: obtaining a firstcontrast value of a first image captured by the image sensor at a firstmoment and a first contrast variation rate of the first image;determining, according to the first contrast value and the firstcontrast variation rate, a first position of the optical device at thefirst moment; moving the optical device from the first position to asecond position corresponding to a second moment subsequent to the firstmoment; and in response to a second contrast variation value being apreset value, determining a current position of the optical device to bethe second position corresponding to the second contrast variationvalue.
 2. The method of claim 1, further comprising: moving the opticaldevice from the second position to a third position corresponding to athird moment subsequent to the second moment, including: determining asecond step size, wherein the second step size is: greater than a firststep size used for moving the optical device to the second position inresponse to be second contrast variation rate exceeding a firstthreshold gradient value, or smaller than the first step size inresponse to the second contrast variation rate not exceeding the firstthreshold gradient value; and moving the optical device from the secondposition to a third position according to the second step size, whereinthe third position of the optical device corresponds to a third momentsubsequent to the second moment.
 3. The method of claim 2, whereindetermining the step size comprises: generating a curve based on aplurality of contrast values including the current contrast value;determining a position of the optical device relative to the imagesensor at which the curve has a peak value; and determining the stepsize using the position of the optical device relative to the imagesensor at which the curve has a peak value.
 4. The method of claim 1,wherein the current contrast value is determined using an average of atleast one luminance gradient value from the current image, a respectiveluminance gradient value being a luminance gradient across a portion ofthe current image.
 5. The method of claim 1, wherein the optical devicemoves relative to the image sensor during an autofocus operation and theautofocus operation is a contrast detection autofocus operation.
 6. Themethod of claim 5, wherein the contrast detection autofocus operationincludes determining the contrast variation rate.
 7. The method of claim1, wherein the contrast value is determined using a pixel subset at aposition corresponding to one of: a selected location, a target, or aportion of a target included in the first image.
 8. The method of claim1, wherein: the current contrast variation rate is a gradient valueindicating a rate of change of a contrast value from a previous image tothe current image; a contrast value difference is a difference betweenthe current contrast value and a contrast value of a previous image; adistance difference is a difference between a current distance betweenthe optical device and the image sensor at which the current image iscaptured and a previous distance between the optical device and theimage sensor at which the previous image was captured; and the rate ofchange of the contrast value is the contrast value difference divided bythe distance difference.
 9. The method of claim 1, further comprising:in response to determining that a third contrast variation rate at athird moment subsequent to the second moment exceeds the secondthreshold gradient value, applying a filter to a plurality of obtainedcontrast values to generate a filtered curve; determining whether thefiltered curve at the second position of the optical device relative tothe image sensor satisfies an end criterion; and in response todetermining that the filtered curve does not satisfy the end criterion,initializing the optical device at an initial position relative to theimage sensor.
 10. The method of claim 9, wherein determining whether thefiltered curve at the second position of the optical device relative tothe image sensor satisfies the end criterion includes determiningwhether a gradient of the filtered curve at the second position of theoptical device relative to the image sensor meets a third thresholdcriterion.
 11. An unmanned aerial vehicle (UAV), comprising: apropulsion system; an imaging device comprising an image sensor and anoptical device; and one or more processors individually or collectivelyconfigured to: obtain a first contrast value of a first image capturedby the image sensor at a first moment and a first contrast variationrate of the first image; determine, according to the first contrastvalue and the first contrast variation rate, a first position of theoptical device at the first moment; move the optical device from thefirst position to a second position corresponding to a second momentsubsequent to the first moment; and in response to a second contrastvariation value being a preset value, determine a current position ofthe optical device to be the second position corresponding to the secondcontrast variation value.
 12. The UAV of claim 11, wherein the one ormore processors are further configured to, individually or collectively,move the optical device from the second position to a third positioncorresponding to a third moment subsequent to the second moment,including: determine a second step size, wherein the second step sizeis: greater than a first step size used for moving the optical device tothe second position in response to be second contrast variation rateexceeding a first threshold gradient value, or smaller than the firststep size in response to the second contrast variation rate notexceeding the first threshold gradient value; and move the opticaldevice from the second position to a third position according to thesecond step size, wherein the third position of the optical devicecorresponds to a third moment subsequent to the second moment.
 13. TheUAV of claim 12, wherein the one or more processors are furtherconfigured to: generate a curve based on a plurality of contrast valuesincluding the current contrast value; determine a position of theoptical device relative to the image sensor at which the curve has apeak value; and determine the step size using the position of theoptical device relative to the image sensor at which the curve has apeak value.
 14. The UAV of claim 11, wherein the current contrast valueis determined using an average of at least one luminance gradient valuefrom the current image, a respective luminance gradient value being aluminance gradient across a portion of the current image.
 15. The UAV ofclaim 11, wherein the one or more processors are further configured tocontrol the optical device move relative to the image sensor during anautofocus operation and the autofocus operation is a contrast detectionautofocus operation.
 16. The UAV of claim 15, wherein the contrastdetection autofocus operation includes determining the contrastvariation rate.
 17. The UAV of claim 11, wherein the contrast value isdetermined using a pixel subset at a position corresponding to one of: aselected location, a target, or a portion of a target included in thefirst image.
 18. The UAV of claim 1, wherein: the current contrastvariation rate is a gradient value indicating a rate of change of acontrast value from a previous image to the current image; a contrastvalue difference is a difference between the current contrast value anda contrast value of a previous image; a distance difference is adifference between a current distance between the optical device and theimage sensor at which the current image is captured and a previousdistance between the optical device and the image sensor at which theprevious image was captured; and the rate of change of the contrastvalue is the contrast value difference divided by the distancedifference.
 19. The UAV of claim 1, wherein the one or more processorsare further configured to: in response to determining that a thirdcontrast variation rate at a third moment subsequent to the secondmoment exceeds the second threshold gradient value, apply a filter to aplurality of obtained contrast values to generate a filtered curve;determine whether the filtered curve at the second position of theoptical device relative to the image sensor satisfies an end criterion;and in response to determining that the filtered curve does not satisfythe end criterion, initialize the optical device at an initial positionrelative to the image sensor.
 20. The UAV of claim 19, wherein the oneor more processors are further configured to determine whether agradient of the filtered curve at the second position of the opticaldevice relative to the image sensor meets a third threshold criterion.